# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=py3c
pkgbase="python-${_realname}"
pkgname=("python-${_realname}")
pkgver=1.2
pkgrel=1
pkgdesc="A Python 2/3 compatibility layer for C extensions"
arch=('i686' 'x86_64')
license=('MIT')
url="https://github.com/encukou/py3c"
depends=("python")
makedepends=("python-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/encukou/py3c/archive/v${pkgver}.tar.gz")
sha256sums=('0e28ea43f5f092967a344294194f55a81fb55adc3c17a0314545d606eb5f6267')
noextract=(${_realname}-${pkgver}.tar.gz)

build() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
  tar -xzf ${srcdir}/${_realname}-${pkgver}.tar.gz -C $srcdir || true

  cd "${srcdir}/${_realname}-${pkgver}"
  /usr/bin/python setup.py build
  make prefix=/usr py3c.pc
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make prefix="$pkgdir"/usr install
  /usr/bin/python setup.py install --prefix=/usr --root="${pkgdir}" -O1

  # Remove headers in broken location
  rm -r "$pkgdir"/usr/include/python*

  install -Dm644 LICENSE.MIT -t "$pkgdir"/usr/share/licenses/$pkgname/
}
